#include<linux/module.h>
#include<linux/kernel.h>
#include<linux/init.h>
#include <linux/platform_device.h>
#include "debug_api.h"

#define DEBUG_LOG_EN

#undef LOG_TAG
#define LOG_TAG "driver_demo"

#define CHAR_DEV_NAME "char_dev_demo"

static int char_dev_probe(struct platform_device *dev)
{
	DEBUG_LOG("probe success!");
	return 0;
}

static int char_dev_remove(struct platform_device *dev)
{
	DEBUG_LOG("device remove!");
	return 0;
}

static const struct of_device_id char_dev_of_match[] = {
	{.compatible = "dts,dts_demo"},
	{},
};

static struct platform_driver char_demo_driver = {
	.driver = {
		.name = CHAR_DEV_NAME,
		.of_match_table = char_dev_of_match,
	},
	.probe = char_dev_probe,
	.remove = char_dev_remove,
};

int init_char_dev(void)
{
	DEBUG_LOG("init!\n");
	platform_driver_register(&char_demo_driver);
	return 0;
}

void exit_char_dev(void)
{
	DEBUG_LOG("exit!\n");
	platform_driver_unregister(&char_demo_driver);
}

MODULE_LICENSE("GPL");
MODULE_AUTHOR("XiaoPeng Chen");

module_init(init_char_dev);
module_exit(exit_char_dev);
